/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package structures.table.action;

/**
 *
 * @author Slayer
 */
public abstract class Action<T> {

    private ActionType type;
    private T value;

    public Action(ActionType type, T value) {
        this.type = type;
        this.value = value;
    }

    public Action(ActionType type) {
        this.type = type;
        this.value = null;
    }

    public T getValue() {
        return value;
    }

    @Override
    public String toString() {
        return type.toString() + value;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Action<T> other = (Action<T>) obj;
        if (this.type != other.type) {
            return false;
        }
        if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 17 * hash + (this.type != null ? this.type.hashCode() : 0);
        hash = 17 * hash + (this.value != null ? this.value.hashCode() : 0);
        return hash;
    }
}
